﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using BUS;

namespace FastDeal
{
    public partial class WebFormDoanhThu : System.Web.UI.Page
    {
        HoaDon_BUS hd_Bus = new HoaDon_BUS();
        List<HoaDon> dsHoaDon = new List<HoaDon>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["DaDangNhap"] == null || (bool)Session["DaDangNhap"] == false)
            {
                Response.Redirect("~/Default.aspx");
            }
            if ((int)Session["LoaiThanhVien"] != 1)
            {
                Response.Redirect("~/Default.aspx");
            }

            int thang = int.Parse(Request.QueryString["Thang"].ToString());
            List<HoaDon> dsHoaDon = new List<HoaDon>();
            dsHoaDon = hd_Bus.LayDanhSach_HoaDon();
            List<HoaDon> dsHoaDon_Thang = new List<HoaDon>();
            dsHoaDon_Thang = dsHoaDon.Where(p => p.NgayDatMua.Month == thang).ToList();
            GV_DSHoaDon.DataSource = dsHoaDon_Thang;
            GV_DSHoaDon.DataBind();

            //Lấy tổng tiền
            double tongTien = 0;
            foreach (HoaDon hd in dsHoaDon_Thang)
            {
                tongTien = tongTien + hd.TongTien;
            }
            lb_tongDoanhThu.Text = tongTien.ToString();

            if (Panel1.Height.Value < 1000)
            {
                Panel1.Height = 1000;
            }
        }
    }
}